<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>火云鞋神官方旗舰店</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/single-goods.css">
    <!--<link rel="stylesheet" href="../layui/css/layui.css" media="all">-->
    <style>
        #ball {
            width:12px;
            height:12px;
            background: #5EA345;
            border-radius: 50%;
            position: relative;
            top: 410px;
            left: 1018px;
            transition: left 1s linear, top 1s ease-in;
        }
    </style>

</head>
<body style="width:100%;height:100%;">
<div class="container-fluid" style="background-color: #F2F2F2">
    <iframe src="../html/head.html" name="ifram12" width="100%" height="260px" scrolling="no" style="border: 0">
    </iframe>

    <div class="row e">
        <div class="col-md-2"></div>
        <div class="col-md-8">
            <div class="row" id="bb">

            </div>
        </div>
        <div class="col-md-2"></div>
    </div>

    <div class="row f">
        <div class="col-md-2"></div>
        <div class="col-md-8 product-label">
            <div>
                <!-- Nav tabs -->
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab"
                                                              data-toggle="tab">商品信息</a></li>
                    <li role="presentation"><a href="#profile" aria-controls="profile" role="tab"
                                               data-toggle="tab">规格保装</a>
                    </li>
                    <li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">售后保障</a>
                    </li>
                </ul>
                <!-- Tab panes -->
                <div class="tab-content" id="rr">
                    <div role="tabpanel" class="tab-pane fade in" id="profile">
                        <h3>规格保装:</h3>
                        <p>这款Earthkeepers City
                            Premium款式采用美丽的优质皮革，牛津布系带风格，可再生橡胶外底和9英寸高，无疑是一款英俊的靴子。为了补充其质朴，引人注目的外观，我们还对内部进行了关注-通过在衬里和内部添加SmartWool®人造羊毛皮</p>
                        <p> 使用我们独家的抗疲劳舒适泡沫技术制作鞋垫，以吸收震动。进口的。系带牛津风格，再生橡胶外底和9英寸高，这款Earthkeepers City
                            Premium风格的靴子无可否认是帅气。为了补充其质朴，引人注目的外观，
                        </p>
                        <h3>DETAILS:</h3>
                        <p>优质抛光全粒面皮革和绒面革鞋面</p>

                        <p>皮革取材于皮革厂，其水，能源和废物管理规范</p>

                        <p> 皮革衬里和鞋垫，带给您优质的感觉和最佳的舒适度</p>

                        <p> SmartWool®人造羊毛内衬由60％美利奴羊毛和40％PET制成</p>

                        <p> 反光鞋垫板可为脚部增添温暖
                        </p>
                    </div>
                    <div role="tabpanel" class="tab-pane fade in" id="messages">
                        <h3>售后保障:</h3>
                        <p> 卖家服务</p>
                        <p> 我方承诺</p>
                        <p> 我方平台卖家销售并发货的商品，由平台卖家提供发票和相应的售后服务。请您放心购买！
                            注：因厂家会在没有任何提前通知的情况下更改产品包装、产地或者一些附件，本司不能确保客户收到的货物与商城图片、产地、附件说明完全一致。只能确保为原厂正货！并且保证与当时市场上同样主流新品一致。若本商城没有及时更新，请大家谅解！
                        </p>
                        <p> 正品行货</p>
                        <p>我方商城向您保证所售商品均为正品行货，京东自营商品开具机打发票或电子发票。</p>
                        <p> 权利声明：</p>
                        <p> 我店上的所有商品信息、客户评价、商品咨询、网友讨论等内容，是京东重要的经营资源，未经许可，禁止非法转载使用。
                            注：本站商品信息均来自于合作方，其真实性、准确性和合法性由信息拥有者（合作方）负责。本站不提供任何保证，并不承担任何法律责任。
                        </p>

                        <p> 价格说明：</p>
                        <P> 我方价：京东价为商品的销售价，是您最终决定是否购买商品的依据。
                        </P>
                        <p>
                            划线价：商品展示的划横线价格为参考价，并非原价，该价格可能是品牌专柜标价、商品吊牌价或由品牌供应商提供的正品零售价（如厂商指导价、建议零售价等）或该商品在京东平台上曾经展示过的销售价；由于地区、时间的差异性和市场行情波动，品牌专柜标价、商品吊牌价等可能会与您购物时展示的不一致，该价格仅供您参考。
                        </p>
                        <p>
                            折扣：如无特殊说明，折扣指销售商在原价、或划线价（如品牌专柜标价、商品吊牌价、厂商指导价、厂商建议零售价）等某一价格基础上计算出的优惠比例或优惠金额；如有疑问，您可在购买前联系销售商进行咨询。
                        </p>
                        <p> 异常问题：商品促销信息以商品详情页“促销”栏中的信息为准；商品的具体售价以订单结算页价格为准；如您发现活动商品售价或促销信息有异常，建议购买前先联系销售商咨询。</p>
                    </div>
                </div>

            </div>

        </div>
        <div class="col-md-2"></div>
    </div>
</div>

<script src="../js/jquery-3.3.1.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/cookie.js"></script>
<script src="../layui/layui.js" charset="utf-8"></script>
<script src="../js/jquery.animate_from_to-1.0.js"></script>
<script>
    $('#myTabs a').click(function (e) {
        e.preventDefault()
        $(this).tab('show')

    })

</script>
<script type="text/javascript">
    window.onload = function () {
        var box = document.getElementsByClassName("box")[0];
        var small = box.firstElementChild || box.firstChild;
        var big = box.children[1];
        var mask = small.children[1];
        var bigImg = big.children[0];
        small.onmouseenter = function () {
            show(mask);
            show(big);
        }
        small.onmouseleave = function () {
            hide(mask);
            hide(big);
        }
        small.onmousemove = function (event) {
            event = event || window.event;
            var pagex = event.pageX || scroll().left + event.clientX;
            var pagey = event.pageY || scroll().top + event.clientY
            var x = pagex - box.offsetLeft - mask.offsetWidth / 2
            var y = pagey - box.offsetTop - mask.offsetHeight / 2
            x = x - 250;
            y = y - 265;
            if (x < 0) {
                x = 0;
            }
            if (x > small.offsetWidth - mask.offsetWidth) {
                x = small.offsetWidth - mask.offsetWidth;
            }
            if (y < 0) {
                y = 0;
            }
            if (y > small.offsetHeight - mask.offsetHeight) {
                y = small.offsetHeight - mask.offsetHeight;
            }
            mask.style.left = x + "px";
            mask.style.top = y + "px";
            var times = bigImg.offsetWidth / small.offsetWidth;
            var _x = x * times;
            var _y = y * times;

            bigImg.style.marginLeft = -_x + "px";
            bigImg.style.marginTop = -_y + "px";
        }
    }
    function show(element) {
        element.style.display = "block";
    }

    function hide(element) {
        element.style.display = "none";
    }
</script>
<script  type="text/javascript">
    var currPage = 1;
    // 每页默认12条数据
    var pageSize = 12
    // 获取传递的参数  /showhero.html?currPage=2--?currPage=2
    var search = location.search
    console.log(search)
    // 按照=对参数分割
    var arr = search.split("=")
    /*console.log(arr.length)*/
    if (arr.length > 1) {
        currPage = arr[1]
    }
    var c
    var userId = getCookie("userid")
    $ball = document.getElementById('ball');
    $.getJSON("http://localhost:8080/nb/nnb/" + currPage, function (data) {
        console.log(data)
        let html = ''
        html += `<div class="col-md-4" style="padding: 0px">
            <h2>${data.goodBrand}</h2>
                    <p style="font-weight: bolder;color: yellowgreen">${data.goodFamily}</p>
                    <div class="box">
                        <div class="small">
                            <img src="${data.goodPhoto}" alt="small Image">
                            <div class="mask"></div>
                        </div>
                        <div class="big" style="z-index: 999">
                            <img src="${data.goodPhoto}" alt="Big Image">
                        </div>
                    </div>
                    </div>
                <div class="col-md-8">
                    <div class="product-price">
                        <h1>${data.goodMoney}$</h1>
                    </div>
                    <div  class="pig"><img id="cart" src="../img/smallpig.svg" alt=""></div>
                    <div style="clear: both"></div>
                    <p class="product-word">${data.goodName}</p>

                    <p class="product-word">选择尺码：
                    <select  id="chima" >
  <option value="38" >38</option>
  <option value="39" >39</option>
  <option value="40">40</option>
  <option value="41" selected>41</option>
  <option value="42">42</option>
  <option value="43">43</option>
  <option value="44">44</option>
</select>
</p>
                    <h4 class="product-right" id="next"><p><img style="width: 40px;margin-left: 30px" src="../img/shopcat.svg" alt=""><a id="shopball" href="#0" onclick="f2(${userId},${data.goodId},${data.goodMoney})"></p>
                    <p>添加购物车
        </p></a></h4>`

        if(userId){
            $.getJSON("http://localhost:8080/judge?userId=" + userId + "&goodId=" + data.goodId, function (da) {
                if (da == "1") {
                    html +=  `<h4 class="product-right" ><p><img id="c1" src="../img/c1.svg" style="width: 40px;display: none" alt=""><img id="c2" src="../img/c2.svg" style="width: 40px;" alt=""></p><p><a href="#0"  onclick="f1(${userId},${data.goodId})">收藏</a></p></h4>
<div style="clear: both"></div>
</div>`
                    $("#bb").append(html)
                }else if (da == "0") {
                    html +=  `<h4 class="product-right" ><p><img id="c1" src="../img/c1.svg" style="width: 40px;" alt=""><img id="c2" src="../img/c2.svg" style="width: 40px;display: none" alt=""></p><p><a href="#"  onclick="f1(${userId},${data.goodId})">收藏</a></p></h4>
<div style="clear: both"></div>
</div>`
                    $("#bb").append(html)
                }
            })
        }else {
            html +=  `<h4 class="product-right" ><p><img id="c1" src="../img/c1.svg" style="width: 40px;" alt=""><img id="c2" src="../img/c2.svg" style="width: 40px;display: none" alt=""></p><p><a href="#"  onclick="f1(${userId},${data.goodId})">收藏</a></p></h4>
<div style="clear: both"></div>
</div>`
            $("#bb").append(html)
        }

        let httml = ''
        httml = `<div role="tabpanel" class="tab-pane fade in active" id="home">
                        <h3>商品信息:</h3>
                        <p>品牌:${data.goodBrand}</p>
                        <p>名称：${data.goodName}</p>
                        <p>鞋面材质：${data.goodMaterial}</p>
                        <p>适用人群：${data.goodSex}</p>
                        <p>鞋品名称：${data.goodUpper}</p>
                        <p>制鞋工艺：${data.goodScience}</p>
                        <p>上市时间：${data.goodDate}</p>
                        <p>店铺：${data.goodFamily}</p>
                    </div>`
        $("#rr").append(httml)

    })
    var n = getCookie("uname")
    var layer
    layui.use('layer', function () {
        layer = layer
    })
    function f1(b, a) {
        if (n != null) {
            $.getJSON("http://localhost:8080/judge?userId=" + b + "&goodId=" + a, function (data) {
                console.log(data)
                if (data == "1") {
                    window.location.href = "http://localhost:8080/deleteCollect/" + b + "/" + a;
                    document.getElementById("c1").style.display="block";
                    document.getElementById("c2").style.display = "none";
                } else if (data == "0") {
                    window.location.href = "http://localhost:8080/addCollect/" + b + "/" + a;
                    document.getElementById("c1").style.display="none";
                    document.getElementById("c2").style.display = "block";
                }
            })
        } else {
            layui.use(['form', 'jquery', 'layer'], function () {
                var form = layui.form
                var layer = layui.layer
                form.render('select');  //刷新select选择框
                form.render('select', 'selectfilter');//刷新layfilter为selectfilter1的select
                layer.msg('只有登录才可以收藏')
            })

        }
    }
    var search = location.search;
    console.log(search)
    var a = search.split(";")
    if( a.length > 1 ){
        layui.use(['form', 'jquery', 'layer'], function () {
            var form = layui.form
            var layer = layui.layer
            form.render('select');  //刷新select选择框
            form.render('select', 'selectfilter');//刷新layfilter为selectfilter1的select
            layer.msg('添加购物车成功！')

        })
    }
    function f2(b, a, c) {
        let  cv = $("#chima option:checked" ).val()
        console.log(cv)
        if (n != null) {
            $.getJSON("http://localhost:8080/depot/selectshoeSize?goodId=" + a + "&goodSize=" +cv ,function (data) {
                console.log(data)
                if(data == "1"){
                    $.getJSON("http://localhost:8080/cart/judge?userId=" + b + "&goodId=" + a, function (data) {
                        console.log(data)
                        if (data == "1") {
                            layui.use(['form', 'jquery', 'layer'], function () {
                                var form = layui.form;
                                // var $ = layui.$;
                                var layer = layui.layer;
                                //可局部刷新的元素 select,radio,checkbox
                                // form.render();          //刷新全部
                                form.render('select');  //刷新select选择框
                                form.render('select', 'selectfilter');//刷新layfilter为selectfilter1的select
                                layer.msg('已添加，不可重复添加')

                            })
                        } else if (data == "0") {

                            window.location.href = "http://localhost:8080/cart/addCart/" + b + "/" + a + "/" + c + "/" + cv;
                        }
                    })
                }else if(data == "0"){
                    layui.use(['form', 'jquery', 'layer'], function () {
                        var form = layui.form;
                        var layer = layui.layer;
                        // form.render();          //刷新全部
                        form.render('select');  //刷新select选择框
                        form.render('select', 'selectfilter');//刷新layfilter为selectfilter1的select
                        layer.msg('没有库存了，添加失败')
                    })
                }
            })
        } else {
            layui.use(['form', 'jquery', 'layer'], function () {
                var form = layui.form;
                var layer = layui.layer;
                form.render('select');  //刷新select选择框
                form.render('select', 'selectfilter');//刷新layfilter为selectfilter1的select
                layer.msg('只有登录才可以加入购物车')
            })

        }
    }
</script>

</body>
</html>